from django.db import models
from django.contrib import admin
from mptt.admin import MPTTModelAdmin

from mptt.models import MPTTModel#, TreeForeignKey

 
class Category(MPTTModel):
    name = models.CharField(max_length=50)
    parent = models.ForeignKey('self', null=True, blank=True, related_name='children')

    def __unicode__(self):
        nlevel = self.get_level()
        szlevel = nlevel * '--'
        name = self.name
        return '%(szlevel)s%(name)s'%locals()

#mptt.register(Category, order_insertion_by=['name'])

'''
class CategoryAdmin(admin.ModelAdmin):
    pass
'''
admin.site.register(Category, MPTTModelAdmin)